package com.joysuch.wwyt.common.controller;

import com.joysuch.wwyt.bp.service.BpWorkSafetyCertService;
import com.joysuch.wwyt.core.common.ajax.ResultBean;
import com.joysuch.wwyt.monitoringcenter.service.AlarmCenterService;
import com.joysuch.wwyt.risk.service.RiskDistrictService;
import com.joysuch.wwyt.risk.service.RiskPointService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * 首页统计
 * @Author ZhangDong
 * @Date 2020/5/25 15:29
 */
@RestController
@RequestMapping("/common/index/statics")
public class IndexStatisticsController {

    @Autowired
    private BpWorkSafetyCertService bpWorkSafetyCertService;
    @Autowired
    private AlarmCenterService alarmCenterService;
    @Autowired
    private RiskPointService riskPointService;
    @Autowired
    private RiskDistrictService riskDistrictService;

    //今日作业数
    @GetMapping("todayCert")
    public ResultBean todayCert(){
        return bpWorkSafetyCertService.todayCert();
    }

    //作业数量统计 默认最近7天
    @GetMapping("certSummary")
    public ResultBean certSummary(){
        return bpWorkSafetyCertService.certSummary();
    }

    //报警统计 days: 从当天开始往前推days天
    @GetMapping("alarmSummary")
    public ResultBean alarmSummary(@RequestParam(value = "days") Integer days) {
        return alarmCenterService.alarmSummary(days);
    }

    //今日报警数
    @GetMapping("todayAlarm")
    public ResultBean todayAlarm(){
        return alarmCenterService.todayAlarm();
    }

    //新增风险点 -当天
    @GetMapping("todayRisk")
    public ResultBean todayRisk(){
        return riskPointService.todayRisk();
    }

    //区域风险等级分布
    @GetMapping("levelSpread")
    public ResultBean levelSpread(){
        return riskDistrictService.levelSpread();
    }

    //新增隐患- 登记但未核销   WorkFlowTypes
    @GetMapping("hideDangerSum")
    public ResultBean hideDangerSum(@RequestParam("type") Integer type){
        //todo
        return ResultBean.success(0);
    }

}
